/**
 * @description 先进先出   API add delete  
 * @description 两个栈实现队列
 */


class MyQueue {
    private stack1:any[] = []
    private stack2:any[] = []

    add(data:any){
        this.stack1.push(data)
    }

    delete(){
        let res;
        let stack1 = this.stack1
        let stack2 = this.stack2

        while(stack1.length){
            let top = stack1.pop()
            if(top !== null){
                stack2.push(top)
            }
            
        }
        res = stack2.pop()

        while(stack2.length){
            let top = stack2.pop()
            if(top !== null){
                stack1.push(top)
            }
        }
        return res || null
    }

    get length(){
        return this.stack1.length
    }
}